package vashion.azeroth.core.manager.impl;

import java.io.Serializable;
import java.util.List;

import vashion.azeroth.core.dao.BaseDao;
import vashion.azeroth.core.manager.BaseManager;
import vashion.azeroth.core.pojo.BaseObject;

public abstract class BaseManagerImpl<Pojo extends BaseObject> implements BaseManager<Pojo> {

	@Override
	public Pojo save(Pojo pojo) {
		int count = getDao().save(pojo);
		if(count > 0)
			return pojo;
		return null;
	}

	@Override
	public int remove(Pojo pojo) {
		return getDao().remove(pojo);
	}
	
	@Override
	public int update(Pojo pojo) {
		int count = getDao().update(pojo);
		return count;
	}

	@Override
	public Pojo get(Serializable id) {
		return getDao().get(id);
	}
	
	@Override
	public List<Pojo> findAll(Pojo pojo) {
		return getDao().findAll(pojo);
	}

	@Override
	public List<Pojo> find(Pojo pojo) {
		return getDao().find(pojo);
	}

	@Override
	public int findCnt(Pojo pojo) {
		return getDao().findCnt(pojo);
	}

	public abstract BaseDao<Pojo> getDao();

}
